<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>算法</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox" style="overflow: hidden">
        <div class="layui-card" lay-filter="" style="height: 100%;">
            <input type="hidden" name="id" id="id" value="${id!}">
            @for(item in EventList!){
                <div class="layui-card-header" style="color: #049590 !important; font-size: 16px;">${item.typeName}</div>
                <div class="layui-card-body layui-row">
                    @for(event in item.list){
                    <div class="layui-col-xs4">
                        <input type="checkbox" name="sf" value="${event.algorithm}" ${(event.algorithm!)=='head'?'disabled':''} ${(event.algorithm!)=='head'?'checked':''} title="${event.eventName}" ${(event.status!)=='1'?'checked':''} lay-skin="primary" style="font-size: 15px;">
                    </div>
                    @}
                </div>
            @}
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="sf-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
        </div>
    </div>
</form>

<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
    layui.use(['table', 'form', 'jquery', 'common', 'select' ], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;
        let select = layui.select;

        let VIEW_PATH = "${ctxPath}/offline/";
        let DATA_PATH = "${ctxPath}/offline/";
        let CAMERA_MANAGE_PATH = "${ctxPath}/api/camera/";
        let t=null;

        form.on('submit(sf-save)', function (data) {
            var id=$("#id").val();
            var event="offline";
            var sfId=[];
            $('input:checkbox[name="sf"]:checked').each(function () {
                sfId.push($(this).val());
            });
            /*
            if(sfId.length==0){
                layer.msg("请选择要启用的算法", {
                    icon: 2,
                    time: 2000
                });
                return;
            }
             */
            let loading = layer.load();
            $.ajax({
                url: DATA_PATH + "startJx?event=" + event+"&id="+id+"&sfId="+sfId,
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.code == 0) {
                        layer.msg("操作成功", {
                            icon: 1,
                            time: 1000
                        }, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("offline-table");
                        });
                    } else {
                        layer.msg("操作失败，"+result.message, {
                            icon: 2,
                            time: 3000
                        },function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("offline-table");
                        });
                    }
                    layer.close(loading);
                }
            })
            return false;
        });
    })
</script>
</body>
</html>
